<?php

namespace App\Http\Middleware;

use App\Exceptions\ServiceException;
use App\Http\Constants\CommonExceptionConstants;
use Closure;
use Illuminate\Support\Facades\Auth;

class ApiAuth
{

    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->guest()) {
            throw new ServiceException(CommonExceptionConstants::getKey('no_login'));
        }
        return $next($request);
    }

}